/*
 * ButtonView.h
 *
 *   This is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Lesser General Public
 *   License as published by the Free Software Foundation; either
 *   version 2 of the License, or (at your option) any later version.
 *
 *   This software is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Lesser General Public License for more details.
 *
 *  Created on: 2010-1-3
 *      Author: Huang Haiyang
 */

#ifndef BUTTONVIEW_H_
#define BUTTONVIEW_H_

#include <coecntrl.h>

namespace view
	{
	class OnClickListener;
	
	class CButtonView : public CCoeControl
		{
		enum{MAX_IMAGE = 50};
	public:
		CButtonView();
		virtual ~CButtonView();
		
	public:
		void SetImageSrc(const TDesC& aSrc);
		TSize Measure(const TSize& aSize);
		void SetOnClickListener(OnClickListener* aListener);
		void SetMapKey(TUint aKey);
		
	public:
		void ConstructL(const TRect& aRect, CCoeControl* aParent);
		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
		void Draw(const TRect& aRect) const;
		
	private:
		void DrawLight(CWindowGc& aGc, const TPoint& aPt) const;
		
		void AnimateClick();
		
	private:
		TUint               iMapKey;
		TBuf<MAX_IMAGE>     iSrcImage;	
		OnClickListener    *iListener;
		
		TBool               iClicking;
		};

	}

#endif /* BUTTONVIEW_H_ */
